import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import routers from './routers';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login.vue')
  },
  {
    path: '/',
    component: () => import('@/layout/layout.vue'),
    redirect: { name: 'index' },
    children: routers.sort((a: any, b: any) => a.meta.sort - b.meta.sort)
  },
  {
    path: '/:pathMatch(.*)',
    redirect: { name: 'login' }
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

export default router;
